require "ImguiWin/BaseImguiWindow"
require "Common/GUIFun"

local P = NewClass(BaseImguiWindow, ClassFromFile(...));


local GUILayout = UnityEngine.GUILayout
local GUI = UnityEngine.GUI
local Screen = UnityEngine.Screen
local dontDestroyObjs = nil

local addSpace = 50

function P:Init(params)

end


function P:Cmd(msg, donClose)
	KBEngineLua.player():sendChatMessage(msg)
	if not donClose then
		self._funObj:Close()
	end
end

function P:Show()
	local space = 0
	GUILayout.BeginArea(self:GetFullScreenAreaRect())
	GUILayout.BeginVertical()



	self.guiInfo.scrollPos = GUILayout.BeginScrollView(self.guiInfo.scrollPos, false, true, GUILayout.Width(Screen.width));
	GUILayout.BeginVertical()
	










	-- lang begin
	GUILayout.BeginHorizontal()
	GUILayout.BeginVertical()

	GUIFun.Label("language: ", false, space)
	if GUIFun.Button("From System", true, 0) then
		Login.SetLang(UnityEngine.SystemLanguage.Unknown)
	end
	
	if GUIFun.Button("English", true, 0) then
		Login.SetLang(UnityEngine.SystemLanguage.English)
	end

	if GUIFun.Button("ChineseSimplified", true, 0) then
		Login.SetLang(UnityEngine.SystemLanguage.ChineseSimplified)
	end

	if GUIFun.Button("ChineseTraditional", true, 0) then
		Login.SetLang(UnityEngine.SystemLanguage.ChineseTraditional)
	end

	if GUIFun.Button("Korean", true, 0) then
		Login.SetLang(UnityEngine.SystemLanguage.Korean)
	end

	GUILayout.EndVertical()

	
	GUILayout.FlexibleSpace()
	GUILayout.EndHorizontal()
	-- lang end






	GUIFun.Label("", true, space)
	GUIFun.Label("", true, space)




	if GUIFun.Button("print lang info", true, 0) then
		logError("lang_info: \n"..LangManager.GetInfo())

		local str = ""
		for k,v in pairs(LuaTextKey) do
			str = str..tostring(k)..": "..tostring(v).."\n"
		end
		logError("lua_text_key: \n"..str)
	end




	GUILayout.EndVertical()
	GUILayout.EndScrollView();


	GUILayout.BeginHorizontal()
	if GUILayout.Button("close", GUIFun.Height(100)) then
		self._funObj:Close()
	end
	GUILayout.EndHorizontal()
	

	GUILayout.EndVertical()
	GUILayout.EndArea()
end

function P:OnGUI()
	GUIFun.Init()
	GUILayout.Box("", GUILayout.Height(Screen.height), GUILayout.Width(Screen.width))
	self:Show()

	local scrollPosition = self.guiInfo.scrollPos
	local scrollDragSpeed = self.guiInfo.scrollDragSpeed

	ImguiWindowCtrl.ScrollByTouch(scrollPosition, scrollDragSpeed)
end

-- function P:Update()
	
-- end